import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:lib_baseview/lib_baseview.dart';

import '../theme/jr.dart';
import '../widget/textfield/jr_edit_text.dart';
import 'dialog_data.dart';

class JRDialogWithType4 extends StatelessWidget {
  final PicTextWithVerticalBtnDialogData data;

  const JRDialogWithType4({Key? key, required this.data}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16.w),
      ),
      width: 280.w,
      padding: EdgeInsets.symmetric(horizontal: 24.w),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Image.asset(
            data.imgAsset,
            width: 120.w,
            height: 120.w,
            fit: BoxFit.contain,
          ),
          SizedBox(
            height: 10.w,
          ),
          Text(
            data.title,
            textAlign: TextAlign.center,
            style: const TextStyle(
              fontSize: 16,
              fontWeight: FontWeight.w600,
              color: Color(0xff333333),
            ),
          ),
          SizedBox(
            height: 12.w,
          ),
          data.descWidget ??
              Text(
                textAlign: TextAlign.center,
                data.desc,
                style: const TextStyle(
                  fontSize: 13,
                  fontWeight: FontWeight.w400,
                  color: Color(0xff666666),
                  height: 22 / 14,
                ),
              ),
          SizedBox(
            height: 24.w,
          ),
          JRButton(
            title: data.firstBtnText,
            onPressed: () async {
              if ((await data.onFirstBtnPress?.call()) ?? true) {
                Navigator.pop(context, true);
              }
            },
            height: 40.w,
          ),
          SizedBox(
            height: 20.w,
          ),
          if (data.secondBtnText.isNotEmpty)
            CupertinoButton(
              onPressed: () async {
                if ((await data.onSecondBtnPress?.call()) ?? true) {
                  Navigator.pop(context, false);
                }
              },
              minSize: 0,
              padding: EdgeInsets.zero,
              child: Text(
                data.secondBtnText,
                style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w400,
                    color: JR.color.secondaryText),
              ),
            ),
          SizedBox(
            height: 24.w,
          ),
        ],
      ),
    );
  }
}
